//
//  NSObjcGCD.h
//  高仿暴走斗图
//
//  Created by key on 16/3/22.
//  Copyright © 2016年 huangsongyao. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "GCDBlock.h"

typedef NS_ENUM(NSUInteger, kQueueType) {
    
    kQueueTypeSERIAL            = 1,    //串行
    kQueueTypeCONCURRENT        = 2,    //并行
    
};

@interface NSObjcGCD : NSObject

/**
 *  gcd后台执行
 *
 *  @param block 执行的block
 */
+ (void)gcd_BackstageExecutionForBlock:(void(^)())block;

/**
 *  gcd创建延迟
 *
 *  @param seconds    延迟时间
 *  @param completion 延迟后执行的block
 */
+ (void)gcd_DelayExecutionForDelayInSeconds:(double)seconds dispatchCompletion:(dispatch_block_t)completion;

/**
 *  gcd创建并行执行汇总的主线程
 *
 *  @param block 汇总主线程的block
 *  @param group dispatch_group_t - group
 */
+ (void)gcd_GatherThreadForMainQueueBlock:(void(^)())block withGroup:(dispatch_group_t)group;

/**
 *  gcd创建并行执行的支线程
 *
 *  @param block 支线程执行的block
 *  @param group 汇总主线程需要的group
 */
+ (void)gcd_CreateDispatchGroupThreadForParallelQueueBlock:(void(^)())block withGroup:(dispatch_group_t)group;

/**
 *  gcd创建并行执行的支线程和主线程
 *
 *  @param queues         支线程的block对象集合
 *  @param mainQueueBlock 主线程的block
 */
+ (void)gcd_CreateDispatchThreadWithParallelQueues:(NSArray<GCDBlock *> *)queues MainQueueBlock:(void(^)())mainQueueBlock;

/**
 *  gcd主线程执行
 *
 *  @param block 主线程执行的block
 */
+ (void)gcd_MainThreadExecutionForBlock:(void(^)())block;

/**
 *  创建队列
 *
 *  @param chars     char
 *  @param queueType 队列类型，枚举
 *  @param block     执行的block
 */
+ (void)gcd_CreateQueueForChar:(const char *)chars withQueueType:(kQueueType)queueType block:(dispatch_block_t)block;

@end


@interface NSObjcGCD(OperationQueue)

/**
 *  创建队列
 *
 *  @param maxConcurrentOperationCount 最大并发执行数
 *  @param operations                  队列操作内容，数组
 *
 *  @return 队列对象
 */
+ (NSOperationQueue *)gcd_OperationQueueWithSetMaxConcurrentOperationCount:(NSInteger)maxConcurrentOperationCount operations:(NSArray<NSOperation *> *)operations;

/**
 *  创建队列操作
 *
 *  @param block           队列操作的内容
 *  @param priority        队列优先级
 *  @param completionBlock 操作完成后的block
 *
 *  @return 队列操作对象
 */
+ (NSBlockOperation *)gcd_OpertionWithBlock:(void(^)(void))block operationQueuePriority:(NSOperationQueuePriority)priority andOpertionCompletionBlock:(void(^)(void))completionBlock;

@end